<!DOCTYPE html>
<html lang="en">
  <head>
    <meta charset="UTF-8" />
    <meta http-equiv="X-UA-Compatible" content="IE=edge" />
    <meta name="viewport" content="width=device-width, initial-scale=1.0" />
    <title>css选择器</title>
  </head>
  <body>
    <div id="box">
      <div>
        <div>
          <span>Hello</span>
        </div>
      </div>
      <div>
        <span>Hello</span>
      </div>
      <div>
        <span>Hello</span>
      </div>
    </div>

    <script>
      // 新的通用选择器: 借用css选择器 实现精准选择
      // #box>div:first-child span

      // querySelector: 查询出元素本身
      // const s = document.querySelector('#box>div:first-child span')

      // querySelectorAll: 所有满足条件的元素, 多个, 存储在 类数组
      // 原型有 forEach 方法, 可用于遍历
      const s = document.querySelectorAll('#box>div:first-child span')

      console.log(s)
    </script>
  </body>
</html>
